/*
 * ContextAdapterDefinition.java
 *
 * Created on 17 de noviembre de 2005, 16:54
 *
 */

package ocp.context.source;

import java.io.Serializable;
import java.util.Vector;
import java.util.Hashtable;
import ocp.context.*;

/**
 * This class represents the definition of a contextual adapter definition, 
 * composed of several contextclass definitions and an adapter definition.
 * @author Ignacio Nieto Carvajal.
 */
public class ContextAdapterDefinition implements Serializable {
    
    protected String name = "";
    protected String owner = "";
    protected String version = "";
    protected ContextClass contextClass = null;
    protected Hashtable adapterMethods = new Hashtable();
    protected String adapterName = "";
    protected String adapterClass = "";

    
    /** Creates a new instance of ContextAdapterDefinition */
    public ContextAdapterDefinition() {
    }
    
    public void setName(String str)                 { name = str; }
    public void setOwner(String str)                { owner = str; }
    public void setVersion(String str)              { version = str; }
    public void setAdapterName(String str)          { adapterName = str; }
    public void setAdapterClass(String str)         { adapterClass = str; }
    public void setContextClass(ContextClass cc)    { contextClass = cc; }
    public void addAdapterMethod(String name, String attribute, String type) {
        adapterMethods.put(name, new AttributeDefinition(attribute, type));
    }
    
    public String getName()                 { return name; }
    public String getOwner()                { return owner; }
    public String getVersion()              { return version; }
    public String getAdapterName()          { return adapterName; }
    public String getAdapterClass()         { return adapterClass; }
    public ContextClass getContextClass()   { return contextClass; }
    public Hashtable getAdapterMethods()    { return adapterMethods; }
    public AttributeDefinition getAdapterMethodAttribute(String name) { return (AttributeDefinition) adapterMethods.get(name); }
    
    public String toString() {
        String tmp = "ContextAdapterDefinition:\nName: "+name+"\nOwner: "+owner+
               "\nVersion: "+version+"\nContext class: "+contextClass.getName()+
               "\nAdapter name: "+adapterName+"\nAdapter class: "+adapterClass;
        tmp +="\nMethods: ";
        for (java.util.Enumeration e = adapterMethods.keys(); e.hasMoreElements(); ) {
            tmp += (String) "\n" + e.nextElement();
        }
        return tmp;
    }
}
